import json

from Page import Page           #导入Page收藏页面类
from Page1 import Pgae1         #导入Page1关注页面类
from selenium import webdriver  #导入web段
import pytest                   #导入pytest包
import time                     #导入时间

@pytest.fixture(scope='function',autouse=True)

#定义json读取方法
# def du(path):
#     with open(path,'r',encoding='utf-8')as f:
#         data = json.load(f)
#         return data

def driver():
    driver = webdriver.Edge()       #打开Edge浏览器
    driver.maximize_window()        #屏幕最大化
    yield driver                    #将浏览器数据返回给driver
    driver.quit()                   #退出浏览器

#调用data来执行数据驱动
# @pytest.mark.parametrize('data',du(r'E:\gaoer\rk\pythonProject\yuekao\baidu.json'))
#调用百度贴吧第一条业务方法
# def test_01_shoucang(driver,data):
#     po = Page(driver)               #设置po为变量名
#     po.luoji_baidu(data['shuruk'])

#调用百度贴吧第一条业务方法
# def test_01_shoucang(driver):
#     po = Page(driver)               #设置po为变量名
#     po.luoji_baidu()

#调用百度贴吧关注第二条业务方法
def test_02_guanzhu(driver):
    po = Pgae1(driver)
    driver.get('https://tieba.baidu.com/')
    time.sleep(2)
    # po.tieba()
    time.sleep(2)
    po.tiyu()
    driver.implicitly_wait(5)
    po.qiehuan3()
    time.sleep(2)
    po.nba()
    time.sleep(2)
    po.qiehuan4()
    time.sleep(2)
    po.guanzhu()
    driver.implicitly_wait(10)